package com.arithmeticEveryDay.blueBridge;

import java.util.Scanner;

/*

状态记录：剩余酒，访问过的店的数量以及花的数量
初始状态：2, 0, 0
最终状态：1, n, m-1
dp[i][j][k]含义：剩余i斗酒，访问过j次店，k次花的前提下，最后一次遇到的是花且正好把酒喝完的情况数


换个思路：
dp[i][j][k]含义：剩余i斗酒，还剩j次店，k次花需要访问的前提下，最后一次遇到的是花且正好喝完的情况数
初始状态：2, n, m
最终状态：1, 0, 1

两个思路都只能过70%，
问题出在初始化，用0作为初始判断的话，有部分搜索结果就是0，重复搜索，导致超时，所以初始化为-1是很有必要的

 */


public class Main2114 {
    
    int n;
    int m;
    int[][][] dp;
    int mod;
    
    
    private Main2114(int n, int m) {
        super();
        this.n = n;
        this.m = m;
        mod = 1000000007;
        dp = new int[m+1][n+1][m+1];
        // 这步初始化很关键，
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                for (int k = 0; k <= m; k++) {
                    dp[i][j][k] = -1;
                }
            }
        }
    }
    
    private int dfs(int wine, int storeVisited, int flowerVisited) {
        if (wine < 0 || wine > m-flowerVisited || storeVisited > n || flowerVisited > m) {
            return 0;
        }
        if (wine == 1 && storeVisited == n && flowerVisited == m-1) {
            return 1;
        }
        if (dp[wine][storeVisited][flowerVisited] == -1) {
            dp[wine][storeVisited][flowerVisited] = (dfs(wine*2, storeVisited+1, flowerVisited) + dfs(wine-1, storeVisited, flowerVisited+1)) % mod;
        }
        return dp[wine][storeVisited][flowerVisited];
    }
    
    private int dfs1(int wine, int storeSurplus, int flowerSurplus) {
        if (wine < 0 || wine > flowerSurplus || storeSurplus < 0 || flowerSurplus < 0) {
            return 0;
        }
        if (wine == 1 && storeSurplus == 0 && flowerSurplus == 1) {
            return 1;
        }
        if (dp[wine][storeSurplus][flowerSurplus] == -1) {
            dp[wine][storeSurplus][flowerSurplus] = (dfs1(wine*2, storeSurplus-1, flowerSurplus) + dfs1(wine-1, storeSurplus, flowerSurplus-1)) % mod;
        }
        return dp[wine][storeSurplus][flowerSurplus];
    }
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        
        Main2114 main = new Main2114(n, m);
        System.out.println(main.dfs(2, 0, 0) % main.mod);
        // System.out.println(main.dfs1(2, n, m));
    }

    
}
